package org.dallasrowing.logbook;

import java.io.File;
import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;

public class Config {

	static Properties conf = new Properties();

	static String getConfig(String key)
	{
		return conf.getProperty(key);
	}
	
	public static Integer[] getColumnWidths()
	{
		String str = conf.getProperty("table.widths");
		StringTokenizer t = new StringTokenizer(str,",");
		ArrayList<Integer> result = new ArrayList<Integer>();
		
		while (t.hasMoreTokens())
		{
			Integer element = Integer.valueOf(t.nextToken());
			result.add(element);
		}
		return result.toArray(new Integer[result.size()]);
	}
	
	public static String getDriver()
	{
		return conf.getProperty("driver");
	}
	
	public static String getJdbcUrl()
	{
		return conf.getProperty("url");
	}

	public static String getJdbcUsername()
	{
		return conf.getProperty("username");
	}

	public static String getJdbcPassword()
	{
		return conf.getProperty("password");
	}

	public static File getReportsDirectory() {
		return new File(conf.getProperty("reportsDir"));
	}

	public static String getTmpReportFile() {
		return conf.getProperty("tmpReportFile");
	}
	
	public static String getOpenReportCmd() {
		return conf.getProperty("showReportCmd");
	}

	public static boolean rowerMissingEnabled() {
		return Boolean.valueOf(conf.getProperty("rowerMissingButtonEnabled", "false"));
	}

	public static Object adminPassword() {
		return conf.getProperty("adminPassword","abc123");
	}
}
